import { apiClient } from './config'
import type {
  SpaceCategoryAnalyzeRequest,
  SpaceCategoryAnalyzeResponse,
  SpaceRankAnalyzeRequest,
  SpaceSizeAnalyzeRequest,
  SpaceSizeAnalyzeResponse,
  SpaceTagAnalyzeRequest,
  SpaceTagAnalyzeResponse,
  SpaceUsageAnalyzeRequest,
  SpaceUsageAnalyzeResponse,
  SpaceUserAnalyzeRequest,
  SpaceUserAnalyzeResponse,
  ApiResponse,
} from '@/types/space-analyze'
import type { Space } from '@/types/space'

/**
 * 空间分析API
 */
export const spaceAnalyzeApi = {
  /**
   * 获取空间图片分类情况
   */
  async getCategoryAnalyze(
    params: SpaceCategoryAnalyzeRequest,
  ): Promise<ApiResponse<SpaceCategoryAnalyzeResponse[]>> {
    return await apiClient.post('/spaceAnalyze/category', params)
  },

  /**
   * 获取空间排行情况（管理员专用）
   */
  async getRankAnalyze(params: SpaceRankAnalyzeRequest): Promise<ApiResponse<Space[]>> {
    return await apiClient.post('/spaceAnalyze/rank', params)
  },

  /**
   * 获取空间图片大小情况
   */
  async getSizeAnalyze(
    params: SpaceSizeAnalyzeRequest,
  ): Promise<ApiResponse<SpaceSizeAnalyzeResponse[]>> {
    return await apiClient.post('/spaceAnalyze/size', params)
  },

  /**
   * 获取空间图片标签情况
   */
  async getTagAnalyze(
    params: SpaceTagAnalyzeRequest,
  ): Promise<ApiResponse<SpaceTagAnalyzeResponse[]>> {
    return await apiClient.post('/spaceAnalyze/tag', params)
  },

  /**
   * 获取空间使用情况
   */
  async getUsageAnalyze(
    params: SpaceUsageAnalyzeRequest,
  ): Promise<ApiResponse<SpaceUsageAnalyzeResponse>> {
    return await apiClient.post('/spaceAnalyze/usage', params)
  },

  /**
   * 获取用户上传行为分析
   */
  async getUserAnalyze(
    params: SpaceUserAnalyzeRequest,
  ): Promise<ApiResponse<SpaceUserAnalyzeResponse[]>> {
    return await apiClient.post('/spaceAnalyze/user', params)
  },
}
